﻿namespace OverStore.Exceptions
{
    using System;
    using System.Globalization;

    /// <summary>
    /// The exception that is thrown when trying to persist instance of type that does not have 
    /// configuration supplied.
    /// </summary>
    public sealed class TypePersistenceNotSupportedException : ArgumentException
    {
        /// <summary>
        /// Initializes new instance of TypePersistenceNotSupportedException.
        /// </summary>
        /// <param name="type">The type which persistence is not supported by current session.</param>
        public TypePersistenceNotSupportedException(Type type)
            : base(String.Format(CultureInfo.InvariantCulture, "Type {0} cannot be persisted", type))
        {
            if (type == null)
                throw new ArgumentNullException("type");
            ErrorType = type;
        }

        /// <summary>
        /// Get type which persistence is not supported.
        /// </summary>
        public Type ErrorType
        {
            get;
            private set;
        }
    }
}